package com.lovar.gaming.common.satoken.config;

import cn.dev33.satoken.dao.SaTokenDao;
import cn.dev33.satoken.jwt.StpLogicJwtForSimple;
import cn.dev33.satoken.stp.StpLogic;
import com.lovar.gaming.common.satoken.service.LovarSaTokenDaoImpl;
import com.lovar.gaming.core.factory.YmlPropertySourceFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;

/**
 * SaToken配置
 *
 * @date 2024/8/8
 */
@Slf4j
@AutoConfiguration
@PropertySource(value = "classpath:default-satoken.yml", factory = YmlPropertySourceFactory.class)
public class SaTokenConfig {

    @Bean
    public StpLogic getStpLogic() {
        log.info("[Bean装配] >>> SaToken Jwt简单实现");
        return new StpLogicJwtForSimple();
    }

    @Bean
    public SaTokenDao getSaTokenDao() {
        log.info("[Bean装配] >>> SaToken 持久层自定义Redis实现");
        return new LovarSaTokenDaoImpl();
    }

}
